package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.*;

import java.util.HashMap;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Classinfo {
    private Long id;

    private String name;

    private Integer number;

    private Employee emp;


    //提供一个json类型的属性
    public String getJson(){
        //创建一个map集合
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("number",number);
        if (emp!=null){
            map.put("empId",emp.getId());
            map.put("empName",emp.getName());
        }
        return JSON.toJSONString(map);
    }

}